using UnityEngine;

[CreateAssetMenu(fileName = "WeaponDetails_", menuName = "游戏SO文件/武器/武器数据文件")]
public class WeaponDetailsSO : ScriptableObject
{
    #region Header WEAPON BASE DETAILS
    [Space(10)]
    [Header("武器基础详细信息")]
    #endregion Header WEAPON BASE DETAILS
    #region Tooltip
    [Tooltip("武器名称")]
    #endregion Tooltip
    public string weaponName;
    #region Tooltip
    [Tooltip("武器的精灵 - 精灵应选中“生成物理形状”选项 ")]
    #endregion Tooltip
    public Sprite weaponSprite;
    
    #region Header WEAPON CONFIGURATION
    [Space(10)]
    [Header("武器配置")]
    #endregion Header WEAPON CONFIGURATION
    #region Tooltip
    [Tooltip("Weapon Shoot Position - 武器末端与精灵枢轴桥的偏移位置")]
    #endregion Tooltip
    public Vector3 weaponShootPosition;
    #region Tooltip
    [Tooltip("武器 当前弹药")]
    #endregion Tooltip
    public AmmoDetailsSO weaponCurrentAmmo;
    #region Tooltip
    [Tooltip("武器射击效果 SO - 包含要与 weaponShootEffectPrefab 结合使用的粒子效果参数 ")]
    #endregion Tooltip
    public WeaponShootEffectSO weaponShootEffect;
    #region Tooltip
    [Tooltip("武器的射击音效")]
    #endregion Tooltip
    public SoundEffectSO weaponFiringSoundEffect;
    #region Tooltip
    [Tooltip("武器的装填音效")]
    #endregion Tooltip
    public SoundEffectSO weaponReloadingSoundEffect;
    
    #region Header WEAPON OPERATING VALUES
    [Space(10)]
    [Header("武器操作值")]
    #endregion Header WEAPON OPERATING VALUES
    #region Tooltip
    [Tooltip("选择武器是否有无限弹药")]
    #endregion Tooltip
    public bool hasInfiniteAmmo = false;
    #region Tooltip
    [Tooltip("选择武器是否具有无限的弹夹容量")]
    #endregion Tooltip
    public bool hasInfiniteClipCapacity = false;
    #region Tooltip
    [Tooltip("武器容量 - 装填前射击")]
    #endregion Tooltip
    public int weaponClipAmmoCapacity = 6;
    #region Tooltip
    [Tooltip("武器弹药容量 - 该武器可以容纳的最大子弹数")]
    #endregion Tooltip
    public int weaponAmmoCapacity = 100;
    #region Tooltip
    [Tooltip("武器射速 - 0.2 表示每秒 5 发")]
    #endregion Tooltip
    public float weaponFireRate = 0.2f;
    #region Tooltip
    [Tooltip("武器预充能时间 - 在射击前按住射击按钮的时间（以秒为单位）")]
    #endregion Tooltip
    public float weaponPrechargeTime = 0f;
    #region Tooltip
    [Tooltip("这是以秒为单位的武器装填时间")]
    #endregion Tooltip
    public float weaponReloadTime = 0f;
    
    #region Validation
#if UNITY_EDITOR

    private void OnValidate()
    {
        HelperUtilities.ValidateCheckEmptyString(this, nameof(weaponName), weaponName);
        HelperUtilities.ValidateCheckNullValue(this, nameof(weaponCurrentAmmo), weaponCurrentAmmo);
        HelperUtilities.ValidateCheckPositiveValue(this, nameof(weaponFireRate), weaponFireRate, false);
        HelperUtilities.ValidateCheckPositiveValue(this, nameof(weaponPrechargeTime), weaponPrechargeTime, true);

        if (!hasInfiniteAmmo)
        {
            HelperUtilities.ValidateCheckPositiveValue(this, nameof(weaponAmmoCapacity), weaponAmmoCapacity, false);
        }

        if (!hasInfiniteClipCapacity)
        {
            HelperUtilities.ValidateCheckPositiveValue(this, nameof(weaponClipAmmoCapacity), weaponClipAmmoCapacity, false);
        }
    }

#endif
    #endregion Validation
}
